package com.briup.day24;

import java.io.*;

/**
 * @author ThinkBook
 */
public class Test04_Change {
    public static void main(String[] args) {
      //test01();
        test02();
    }
    public static void test02(){
        InputStreamReader fs = null;
        try {
            FileInputStream  fns = new FileInputStream("src/file/test_anis.txt");
            fs = new InputStreamReader(fns, "gb2312");
            char[] c = new char[1024];
            int len = -1;
            while ((len = fs.read(c)) != -1){
                System.out.print(new String(c, 0, len));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (fs !=null){
                try {
                    fs.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public static void test01(){
        FileReader fr = null;
        try {
             fr = new FileReader("src/file/test_anis.txt");
             char[] c = new char[1024];
             int len = -1;
             while ((len=fr.read(c))!=-1){
                 System.out.print(new String(c, 0, len));
             }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (fr !=null){
                try {
                    fr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
